<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>立方体练习</title>
    <style>
        *{
            padding: 0;
            margin: 0;
        }

        html, body{
            height: 100%;
            overflow: hidden;
        }
        .wrap{
            position: absolute;
            top: 0;
            left: 0;
            bottom: 0;
            right: 0;
            width: 400px;
            height: 400px;
            margin: auto;
            background-color: #acf;
            perspective: 400px;
        }
        .box{
            position: relative;
            left: 50%;
            top: 50%;
            width: 200px;
            height: 200px;
            margin: -100px 0 0 -100px;
            transition: transform 3s ease-in;
            transform-style: preserve-3d;
            transform-origin: 50% 50% -100px;
            transform: rotateX(0deg) rotateY(0deg);
        }
        .box div{
            position: absolute;
            left: 0;
            top: 0;
            width: 200px;
            height: 200px;
            background-color: pink;
            text-align: center;
            line-height: 200px;
            font-size: 64px;
            transform-origin: 50% 50% -100px;
            backface-visibility: hidden;
        }
        .box div:nth-child(1){

        }
        .box div:nth-child(2){
            transform: rotateX(180deg);
        }
        .box div:nth-child(3){
            transform: rotateX(90deg);
        }
        .box div:nth-child(4){
            transform: rotateX(270deg);
        }
        .box div:nth-child(5){
            transform: rotateY(270deg);
        }
        .box div:nth-child(6){
            transform: rotateY(90deg);
        }
        .wrap:hover .box{
            transform: rotateX(360deg) rotateY(360deg);
        }
    </style>
</head>
<body>
    <div class="wrap">
        <div class="box">
            <div>前</div>
            <div>后</div>
            <div>上</div>
            <div>下</div>
            <div>左</div>
            <div>右</div>
        </div>
    </div>
</body>
</html>